﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace G.Service.Data
{
    public class APPTestProjectData : BaseData
    {
        public void AddAPPTestProject(int userId, string projectName, string projectConfig)
        {
            this.Entities.AddToAPITestProjects(new APITestProject() { UserId = userId, ProjectName = projectName, ProjectConfig = projectConfig });
        }

        public APITestProject GetAPITestProject(int userId, string projectName)
        {
            return this.Entities.APITestProjects.FirstOrDefault(c => c.UserId == userId && c.ProjectName == projectName);
        }

        public void UpdateProjectConfig(APITestProject project, string projectConfig)
        {
            project.ProjectConfig = projectConfig;
        }

        public APITestProject[] GetAllAPITestProjects()
        {
            return this.Entities.APITestProjects.ToArray();
        }

        public APITestProject[] GetAllAPITestProjectsByUserId(int userId)
        {
            return this.Entities.APITestProjects.Where(c => c.UserId == userId).ToArray();
        }
    }
}
